import pymysql

#创建数据库连接
conn = pymysql.connect(host="192.168.40.143", user="root", password="123456", database="litemall", port=3306)

#创建游标cursor
cursor = conn.cursor()

#执行SQL
cursor.execute("select id, name from litemall_goods")

#取1行
print("cursor.rownumber=", cursor.rownumber)
print(cursor.fetchone())
print("cursor.rownumber=", cursor.rownumber)

#取3行
print(cursor.fetchmany(3))
print("cursor.rownumber=", cursor.rownumber)

#取剩下全部
print(cursor.fetchall())
print("cursor.rownumber=", cursor.rownumber)



#关闭游标
cursor.close()

#关闭连接
conn.close()
